package superman.app.gr100.biz.gr_expapp;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

import org.json.JSONException;
import org.json.JSONObject;

public class ResultActivity extends Activity {
//	private ImageView mResultImage;
	private TextView mResultText;
	private String result;
	private String OID;
	private Button killOrder;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_result);
		Bundle extras = getIntent().getExtras();
//		mResultImage = (ImageView) findViewById(R.id.result_image);
		mResultText = (TextView) findViewById(R.id.result_text);
		killOrder = (Button) findViewById(R.id.killOrder);
		if (null != extras) {
			int width = extras.getInt("width");
			int height = extras.getInt("height");
			LayoutParams lps = new LayoutParams(width, height);
			lps.topMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
			lps.leftMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics());
			lps.rightMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics());
//			mResultImage.setLayoutParams(lps);
			result = extras.getString("result");
			mResultText.setText(result);
//			Bitmap barcode = null;
//			byte[] compressedBitmap = extras.getByteArray(DecodeThread.BARCODE_BITMAP);
//			if (compressedBitmap != null) {
//				barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);
//				barcode = barcode.copy(Bitmap.Config.RGB_565, true);
//			}
//			mResultImage.setImageBitmap(barcode);
			Log.d("result", result);
			try {
				JSONObject jsonObject = new JSONObject(result);
				 OID = (String) jsonObject.get("OID");
				mResultText.setText(OID);
			} catch (JSONException e) {
				mResultText.setText("没有扫描到有效信息");
			}
		}
		killOrder.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
			}
		});
	}

}
